﻿FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443

FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
ARG BUILD_CONFIGURATION=Release
WORKDIR /src
COPY ["WeatherHistory.Api/WeatherHistory.Api.csproj", "WeatherHistory.Api/"]
COPY ["WeatherHistory.Api.CommandsQueries/WeatherHistory.Api.CommandsQueries.csproj", "WeatherHistory.Api.CommandsQueries/"]
COPY ["WeatherHistory.Shared/WeatherHistory.Shared.csproj", "WeatherHistory.Shared/"]
COPY ["WeatherHistory.Data/WeatherHistory.Data.csproj", "WeatherHistory.Data/"]
RUN dotnet restore "WeatherHistory.Api/WeatherHistory.Api.csproj"
COPY . .
WORKDIR "/src/WeatherHistory.Api"
RUN dotnet build "WeatherHistory.Api.csproj" -c $BUILD_CONFIGURATION -o /app/build

FROM build AS publish
ARG BUILD_CONFIGURATION=Release
RUN dotnet publish "WeatherHistory.Api.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "WeatherHistory.Api.dll"]
